<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>	
<%@ include file="/pub/headmeta.jsp" %>
</head>
<body>
	<div class="right-head"><span class="right-head-font">投诉建议</span></div>
	
	<form id="queryForm" method="post">
	<div class="term">
		<div class="div1-2">标题：</div>
		<div class="div2"><input type="text" name="q_title" id="q_title"/></div>
		<div class="div1-2">邮箱/手机：</div>	
		<div class="div2"><input type="text" name="q_phone" id="q_phone"/></div>	
		<div class="div1-2">描述：</div>
		<div class="div2"><input type="text" name="q_content" id="q_content"/></div>
		<br style="clear:both;" /><br />
	</div>
	<div class="function-bar">
		<div class="div0"><input  type="button" class="button-bar" value="重置条件" onclick="resetEx(this.form);"/></div>
		<div class="div0"><input  type="button" class="button-bar" value="查询" onclick="setCurPage(1);doQuery();"/></div>
		<div class="div0"><input  type="button" class="button-bar" value="删除" onclick="doDel();" ${f:op(ops,'投诉建议','删除')}/></div>
	</div>	
	</form>
	
	<form id="delForm" method="post">
	<table id="MyTableList" width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="table-form">
		<tr align="center" class="STYLE1">
			<th width="5%"><input id="ckAll" type="checkbox" onclick="checkAll(this.checked,'cb');" /></th>
			<th width="5%">序号</th>
			<th width="90%">投诉建议</th>
		</tr>
	</table>
	<%@ include file="/pub/pageLink.jsp" %>
	</form>	
</body>
</html>
<script type="text/javascript">
<!--
//自动调用初始化
$(document).ready(function(){	
	//查询
	doQuery();
});
var listData;//记录当前页数据
//查询
function doQuery(){	
	var page=getPage();
	var pageSize=getPageSize();
	var url="${ctx}/suggest!getList.action?page="+page+"&pageSize="+pageSize;
	$.post(url, $("#queryForm").serialize() ,function callback(txt){   
			var json = $.parseJSON(txt);
			if (json.code==0) {	
				setRecordCount(json.count);
				listData=json.info;
				createTable(listData,page,pageSize);				
			}else{
				alert('查询失败！');
			}
		}	
	);
	$('#ckAll').attr("checked",false);
}



//创建表数据
function createTable(objs,page,pageSize){	
	var table=document.getElementById('MyTableList');
	for( var i=table.rows.length-1; i>0; i--){
		table.deleteRow(i); 
	}
	var b=document.createElement("tbody");
	for(var i=0;i<objs.length;i++){
		var obj=objs[i];
		var row=document.createElement("tr");	
		row.align="center";	
		//
		var c="<table width='100%'>";
		c+="<tr><td width='70%'>标题："+obj.title+"</td><td width='30%' align='right'><a  class='edit-font' title='联系方式："+obj.phone+"'>"+obj.custAccount+"</a>&nbsp;&nbsp;&nbsp;"+formatDate(obj.createTime)+"&nbsp;&nbsp;&nbsp;</td></tr>";
		c+="<tr><td colSpan='2'>内容："+obj.content+"</td></tr>";
		c+="<tr><td colSpan='2'>图片：<img src='${ctx}/sys!getPic.action?name="+obj.pic+"'/></td></tr>";
		c+="</table>"
		//
		var c1=document.createElement("td");	
		c1.innerHTML="<input name='cb' type='checkbox' value='"+obj.id+"'/>";
		var c2=document.createElement("td");	
		c2.innerHTML=(page-1)*pageSize+i+1;
		var c3=document.createElement("td");	
		c3.innerHTML=c;	
		
		row.appendChild(c1);
		row.appendChild(c2);
		row.appendChild(c3);	
		
		setTdStyle(row);
		b.appendChild(row);
	}
	table.appendChild(b);
}

//删除
function doDel(){
	if(ifCheck('cb')){
		if(confirm('确定要删除选中的记录吗？')){
			var url="${ctx}/suggest!remove.action";
			$.post(url, $("#delForm").serialize() ,function callback(txt){   
					var json = $.parseJSON(txt);
					if (json.code==0) {	
						doQuery();			
					}else{
						alert('删除失败！');
					}
				}	
			);			
		}
	}else{
		alert('请先勾选记录！');
	}
}
//格式化日期：yyyy-MM-dd HH:mm:ss
function formatDate(time){
	var date=new Date(time);
	var m = date.getMonth()+1;
	var d = date.getDate();
	var H=date.getHours();
	var n=date.getMinutes();
	var s=date.getSeconds();
	return date.getFullYear()+"-"+(m<10?('0'+m):m)+"-"+(d<10?('0'+d):d)+" "+(H<10?('0'+H):H)+":"+(n<10?('0'+n):n)+":"+(s<10?('0'+s):s);
}
//-->
</script>
